<?php
require_once("../model/postBmsDao.php");
require_once("../model/replyBmsDao.php");
// 显示所有用户信息
if(isset($_GET['action']) && $_GET['action'] =="delete_post"){
  delete_post($_GET['topic_id']);
  header("location:../views/indexBms.php?action=post"); 
}
if(isset($_GET['replyId'])){
  delete_reply($_GET['replyId']);
  header("location:../views/indexBms.php?action=comment");
}
if(isset($_GET['topicId'])){
  set_post_good($_GET['topicId'],$_GET['isgood']);
  header("location:../views/indexBms.php?action=post");
}
if(isset($_POST['boardName'])){  
  if(!add_board($_POST['boardName'])){
    header("location:../views/indexBms.php?action=post&board=1&error=版块已存在");
    exit;
  }
  header("location:../views/indexBms.php?action=post&board=1");  
}
if(isset($_GET['action']) && $_GET['action'] == "delete_board"){
  $boardId = $_GET['boardId'];
  if(get_posts_by_board($boardId)){
    header("location:../views/indexBms.php?action=post&board=1&error=该版块下有帖子，请先删除帖子");
    exit;
  }
  delete_board($boardId);
  echo $boardId;
  header("location:../views/indexBms.php?action=post&board=1");
}
?>